package cn.tedu.boot21.controller;

import cn.tedu.boot21.entity.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ReController {
//    @RequestMapping("/hello")
//    private void hello(HttpServletResponse response) throws IOException {
//        response.setContentType("text/html;charset=utf-8");
//        PrintWriter pw = response.getWriter();
//        pw.write("<h1 style='text-align: center'>测试成功!</h1>");
//        pw.close();
//    }

    @RequestMapping("/hello")
    @ResponseBody   //SpringMVC框架提供的注解,作用:可以通过返回值的方式给客户端响应数据
    private String hello(){
        return "测试成功!222";
    }

//    @RequestMapping("/param1")
//    @ResponseBody
//    private String param(HttpServletRequest request){
//        String line = request.getParameter("info");
//        return "接受到了参数: "+line;
//    }

    @RequestMapping("/param2")
    @ResponseBody
    private String param(String username,int age){
        return "名字: "+username+"<br><hr>"+"年龄: "+age;
    }

    @RequestMapping("/param3")
    @ResponseBody
    private String param(Emp emp){
        return emp.toString();
    }



}
